<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录 | 灵光显卡铺</title>
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/login.css">
</head>
<body>
<?php include_once 'header_non2floor.php'?>
<main style="margin-top: 45px" class="clearfix">
    <div class="container title">
        <p>登录到</p>
        <p>灵光显卡铺</p>
    </div>
    <div class="container loginForm">
        <form action="connect.php" method="post">
            <input type="text" name="username" id="username" placeholder="您的用户名">
            <input type="password" name="password" id="password" placeholder="您的密码">
            <div>
                <input type="submit" value="登录">
            </div>
        </form>
    </div>
    <div class="toReg container">
        <div class="regTitle"><p>如果您没有账号... 当然我们希望您能拥有一个</p></div>
        <div class="regBtn">
            <button id="toReg">注册</button>
            或
            <button id="toIndex">返回首页</button>
        </div>
    </div>
</main>
<?php include_once 'loginLayout.php'?>
</body>
<script src="./js/tools.js"></script>
<script src="./js/header.js"></script>
<script>
    document.getElementById('toReg').onclick = function(){
        window.location.href = 'register.php'
    }
    document.getElementById('toIndex').onclick = function(){
        window.location.href = 'index.php'
    }
</script>
<script src="./js/jquery-3.5.1.js"></script>
<script>
    $(':submit').click(function (){
        $.post('connect.php',{
            username: $('#username').val(),
            password: $('#password').val(),
            type: 'login'
        },function (data){
            if(data === '0'){
                alert('用户名或密码错误')
            }else if(data === '1'){
                alert('登录成功')
                window.location.href = "index.php"
            }else{
                console.log(data)
            }
        })

        return false
    })
</script>
</html>